package com.hzlj.position.locate.common.enums;

import com.fz.common.base.exception.PubError;
import com.fz.common.base.exception.PubException;
import lombok.Getter;

/**
 * @author fanzhuo
 */

@Getter
public enum PositionCorrectStatus {
    INIT("00", "未纠偏"),
    SEND_NOTICE("01", "发起纠偏"),
    REPORT("02", "纠偏上报"),
    MANUAL_COMPLETE("03", "手工纠偏"),
    SYSTEM_COMPLETE("04", "自动纠偏"),
    ;

    private final String code;
    private final String text;

    PositionCorrectStatus(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public static PositionCorrectStatus of(String value) {
        for (PositionCorrectStatus reportType : values()) {
            if (reportType.getCode().equals(value)) {
                return reportType;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }

    public static PositionCorrectStatus ofName(String name) {
        for (PositionCorrectStatus reportType : values()) {
            if (reportType.name().equalsIgnoreCase(name)) {
                return reportType;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }
}
